package org.taobao.ibatiside.ui.adapter;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.WorkbenchAdapter;
import org.taobao.ibatiside.core.IbatisConstant;
import org.taobao.ibatiside.core.filemodel.IbatisStatement;
import org.taobao.ibatiside.ui.Activator;

public class StatementAdapter extends WorkbenchAdapter {
	private final IbatisStatement stmt;

	public StatementAdapter(IbatisStatement stmt) {
		super();
		this.stmt = stmt;
	}
	@Override
	public String getLabel(Object object) {
		return stmt.getId();
	}
	@Override
	public ImageDescriptor getImageDescriptor(Object object) {
		return stmt.getCategory() == IbatisConstant.STMT_DELETE ? Activator.getIcon("op16/delete.png") :
			stmt.getCategory() == IbatisConstant.STMT_UPDATE ? Activator.getIcon("op16/update.png") :
				stmt.getCategory() == IbatisConstant.STMT_SELECT ? Activator.getIcon("op16/select.png") :
					stmt.getCategory() == IbatisConstant.STMT_INSERT ? Activator.getIcon("op16/insert.png") :
						stmt.getCategory() == IbatisConstant.STMT_PROCEDURE ? Activator.getIcon("op16/procedure.png") : Activator.getIcon("op16/statement.png");
	}
	@Override
	public Object getParent(Object object) {
		return stmt.getParent();
	}
}
